Skip to content

Removed the hash salt when calculating the hash of the device's MAC address#482

Open
this-Aditya wants to merge 2 commits intomasterfrom
remove-salt
Open

Removed the hash salt when calculating the hash of the device's MAC address#482
this-Aditya wants to merge 2 commits intomasterfrom
remove-salt

Conversation

@this-Aditya
Copy link
Member

No description provided.

Base automatically changed from dev to master October 23, 2025 10:36
@this-Aditya this-Aditya requested a review from Copilot January 20, 2026 11:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request removes the hash salt mechanism from Bluetooth MAC address hashing. The changes simplify the code by eliminating the randomized salt that was previously concatenated to MAC addresses before hashing, removing related SharedPreferences storage logic, and cleaning up unused imports.

Changes:

  • Removed hash salt generation and storage logic that used SharedPreferences and ThreadLocalRandom
  • Updated MAC address hashing to use the raw MAC address without salt concatenation
  • Removed the hashSaltReference field from PhoneBluetoothDeviceScanned messages
  • Improved code readability by replacing magic numbers (10, 11, 12) with BluetoothDevice constants (BOND_NONE, BOND_BONDING, BOND_BONDED) in the toPairedState() function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +128 to 133
send(bluetoothScannedTopic, PhoneBluetoothDeviceScanned.newBuilder().apply {
this.time = currentTime
this.timeReceived = currentTime
this.macAddressHash = macAddressHash
this.pairedState = device.bondState.toPairedState()
this.hashSaltReference = hashSaltReference
}.build())
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the hashSaltReference field from PhoneBluetoothDeviceScanned messages represents a breaking API change. Consumers of this data who expect or rely on this field will experience issues when this change is deployed. This change should be coordinated with downstream systems, and the schema should be updated to mark this field as optional or deprecated before removing it from the code, following proper schema evolution practices.

Copilot uses AI. Check for mistakes.
time = currentTime
timeReceived = currentTime
}
val macAddressHash: ByteBuffer = hashGenerator.createHashByteBuffer(macAddress)
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the hash salt makes MAC address hashes deterministic across all devices and time periods. This significantly weakens privacy protection because the hashes can potentially be reversed using rainbow tables or dictionary attacks on known MAC address patterns. The same MAC address will always produce the same hash, making it easier to track devices across different users or time periods. If privacy is a concern, consider keeping the salt or using a more secure hashing approach with proper key derivation.

Copilot uses AI. Check for mistakes.
pairedDevices.forEach { bd ->
val mac = bd.address
val hash = hashGenerator.createHashByteBuffer(mac + "$hashSaltReference")
val hash = hashGenerator.createHashByteBuffer(mac)
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the hash salt makes MAC address hashes deterministic across all devices and time periods. This significantly weakens privacy protection because the hashes can potentially be reversed using rainbow tables or dictionary attacks on known MAC address patterns. The same MAC address will always produce the same hash, making it easier to track devices across different users or time periods. If privacy is a concern, consider keeping the salt or using a more secure hashing approach with proper key derivation.

Copilot uses AI. Check for mistakes.
Comment on lines 121 to 124
send(bluetoothScannedTopic, scannedTopicBuilder.apply {
this.macAddressHash = hash
this.pairedState = bd.bondState.toPairedState()
this.hashSaltReference = hashSaltReference
}.build())
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the hashSaltReference field from PhoneBluetoothDeviceScanned messages represents a breaking API change. Consumers of this data who expect or rely on this field will experience issues when this change is deployed. This change should be coordinated with downstream systems, and the schema should be updated to mark this field as optional or deprecated before removing it from the code, following proper schema evolution practices.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants